package com.mango.request;

import android.support.annotation.Nullable;

import com.mango.volley.Response;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.AbstractMap.SimpleEntry;

public class ReqMgWallExchange extends ReqMango<SimpleEntry<Integer, String>> {
    public ReqMgWallExchange(String appID, String appKey, String uid, double integral,
                             @Nullable Response.Listener<SimpleEntry<Integer, String>> listener,
                             @Nullable Response.ErrorListener errorListener) {
        super("api/wall/exchange", new Object[]{"uid", uid, "integral", integral,
                "appId", appID, "timeStamp", System.currentTimeMillis(), null, appKey}, listener, errorListener);
    }

    @Override
    protected String getJsonParams() {
        return null;
    }

    @Override
    protected SimpleEntry<Integer, String> parseJsonResult(String json) throws JSONException {
        JSONObject result = new JSONObject(json);
        return new SimpleEntry<>(result.getInt("code"), result.getString("msg"));
    }
}
